<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
        crossorigin="anonymous">
    <title>商户信息修改</title>
    <style>
        form{
        padding: 40px 0px;
    }
    </style>
</head>

<body>
    <div class="container">
        <form class="form-horizontal">
            <div class="form-group">
                <label for="inputEmail3" class="col-sm-2 control-label">编号: </label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="inputEmail3" disabled name="id">
                    <input type="hidden" id="hid" name="id">
                </div>
            </div>
            <div class="form-group">
                <label for="inputEmail4" class="col-sm-2 control-label">PID: </label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="inputEmail4" placeholder="商户PID" name="pid">
                </div>
            </div>
            <div class="form-group">
                <label for="inputEmail5" class="col-sm-2 control-label">MD5: </label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="inputEmail5" placeholder="商户MD5" name="md5">
                </div>
            </div>
            <div class="form-group">
                <label for="inputPassword3" class="col-sm-2 control-label">备注: </label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="inputPassword3" placeholder="备注信息" name="info">
                </div>
            </div>

            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button type="button" class="btn btn-info" id="btn">修改</button>
                </div>
            </div>
        </form>
    </div>
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
    <script>
        var id = location.search.substr(4);
        // console.log(id)
        $.ajax({
            url: './shopinfo.php',
            data: {
                id: id
            },
            dataType: 'json',
            success: function (msg) {
                console.log(msg)
                $('#inputEmail3').val(msg.id)
                $('#inputEmail4').val(msg.pid)
                $('#inputEmail5').val(msg.md5)
                $('#inputPassword3').val(msg.info)
                $('#hid').val(msg.id)
            }
        })


        $('#btn').click(function () {
            var data = $('form').serialize();
            console.log(data)
            $.ajax({
                url: './updateshopinfo.php',
                data: data,
                type:'post',
                success:function(msg){
                    // console.log(msg)
                    if(msg==1){
                        alert('商户信息修改成功')
                        location.href='./index.html'
                    }else{
                        alert('修改失败')
                        location.reload()
                    }
                }
            })


        })
    </script>
</body>

</html>